package com.mathdroid.gui.main.browser;

import com.mathdroid.model.items.Item;

import java.util.Comparator;

/**
 * This comparator compares items by their rating.
 * @param <T> Object to compare.
 */
public final class RatingComparator<T> implements Comparator<Item> {

	@Override
	public int compare(final Item i, final Item j) {
		if (i.getRating() > j.getRating()) {
			return -1;
		} else if (i.getRating() < j.getRating()) {
			return 1;
		}
		return 0;
	}

}
